package com.lindroy.androidplayer.logic.model

import com.lindroy.androidplayer.logic.network.base.BaseResponse
import com.lindroy.androidplayer.logic.network.base.http.RequestException

/**
 * @author Lin
 * @date 2021/10/14
 * @function 请求结果
 */
open class ApiResponse<T>(
    override val data: T? = null,
    override val errorCode: Int? = null,
    override val errorMsg: String? = null,
) : BaseResponse<T>() {

    constructor(exception: RequestException) : this(null, exception.code, exception.errorMsg)

    override val success: Boolean
        get() = errorCode == 0
}

class StartResponse<T> : ApiResponse<T>()

class CompletionResponse<T> : ApiResponse<T>()

data class SuccessResponse<T>(override val data: T) : ApiResponse<T>(data = data)

class EmptyResponse<T> : ApiResponse<T>()

data class FailureResponse<T>(val exception: RequestException) :
    ApiResponse<T>(exception = exception)

